package lovo01.lesson05;

import javax.swing.*;

public class Transition01 {
    public static void main(String[] args) {
        String sun = "[a-z]{1,}[_][a-z]{1,}";
        while (true){
            String name = JOptionPane.showInputDialog("请输入蛇形命名法的单词：");
            if (name.matches(sun)){
                int index = name.indexOf("_");
                for (int i = 0;i < name.length();i++){
                    char[] charAry = name.toCharArray();
                    if (i == index){
                        continue;
                    }else if (i ==(index + 1)){
                        charAry[i] -= 32;
                        System.out.print(charAry[i]);
                    }else {
                        System.out.print(charAry[i]);
                    }
                }
                break;
            }else {
                JOptionPane.showMessageDialog(null, "输入错误，请重新输入");
            }
        }
    }
}
